package com.digital.smartgrow.service.title;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.digital.smartgrow.dao.title.WorkingConditionsMapper;
import com.digital.smartgrow.dto.title.WorkingConditions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class WorkingConditionsServiceImpl implements WorkingConditionsService{


    @Autowired
    WorkingConditionsMapper workingConditionsMapper;


    @Override
    @Transactional
    public List<WorkingConditions> findList(WorkingConditions workingConditions) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("idcard",workingConditions.getIdcard());
        queryWrapper.eq("status",0);
        return workingConditionsMapper.selectList(queryWrapper);
    }

    @Override
    @Transactional
    public void deleteCommend(WorkingConditions workingConditions) {
        WorkingConditions workingConditions1 = new WorkingConditions();
        Date date = new Date();
        workingConditions1.setStatus(1).setId(workingConditions.getId()).setTime(date);
        workingConditionsMapper.updateById(workingConditions1);
    }
}
